package response

type ResCode int64

const (
	CodeSuccess = 2000 + iota
	CodeParamError
	CodeServerBusy
	CodeIllegalLogin
	CodeLoginFailure
	CodeTokenInvalid
	CodeRoleNoExit
	CodeUserNoExit
	CodeUserExist
	CodeRoleExist
	DataInWrongFormat
	DatabaseException
	UploadFileFail
	ServerException
	BuildIsExist
	GetFileFail
	CodeNoFixedTimeSignIn
	CodeReserveIsEmpty
	CodeReSignIn
	CodeOutOfRange
	CodeAlreadyReserve
	CodeReserveExist
	BuildNoExist
	ClassroomIsExist
	CampusNoExists
	CodeSeatNoExit
	CodeSeatStop
	CodeStudentIsViolate
	CodeRoleStop
	CodeSignFail
	CodeSignOverTime
	CodeViolationCancel
	CodeUserCancel
	CodeTimeExist
	CodeOutOfTime
	NoReserve
	CodeRenewalTime
	CodeRenewal
	CreditRecordInformationNoExist
	AccountOrPasswordIsError
)

var codeMsgMap = map[ResCode]string{
	CodeSuccess:                    "success",
	CodeParamError:                 "请求参数错误",
	CodeServerBusy:                 "服务繁忙",
	CodeIllegalLogin:               "未登录或非法访问",
	CodeLoginFailure:               "账户异地登录或令牌失效",
	CodeTokenInvalid:               "无效的Token",
	CodeRoleNoExit:                 "角色不存在",
	CodeUserNoExit:                 "用户不存在",
	CodeUserExist:                  "用户已存在",
	CodeRoleExist:                  "角色存在",
	DataInWrongFormat:              "数据格式错误",
	DatabaseException:              "数据库异常",
	UploadFileFail:                 "文件上传失败",
	ServerException:                "服务器异常",
	BuildIsExist:                   "楼栋已经存在",
	GetFileFail:                    "获取模板文件失败",
	CodeNoFixedTimeSignIn:          "未在规定时间签到",
	CodeReserveIsEmpty:             "预约记录为空",
	CodeReSignIn:                   "重复签到",
	CodeOutOfRange:                 "超出范围",
	CodeAlreadyReserve:             "位置已被预约",
	CodeReserveExist:               "预约已存在",
	BuildNoExist:                   "楼栋不存在",
	ClassroomIsExist:               "部分教室已存在",
	CampusNoExists:                 "校区不存在",
	CodeSeatNoExit:                 "座位不存在",
	CodeSeatStop:                   "座位停用",
	CodeStudentIsViolate:           "违规状态",
	CodeRoleStop:                   "当前用户的角色已被禁用",
	CodeSignFail:                   "签到失败",
	CodeSignOverTime:               "签到时间已过",
	CodeViolationCancel:            "违规取消",
	CodeUserCancel:                 "用户取消",
	CodeTimeExist:                  "已预约",
	CodeOutOfTime:                  "预约时间不能超过16个小时",
	NoReserve:                      "位置无人预约，无法申诉",
	CodeRenewalTime:                "不可逾越时间段",
	CodeRenewal:                    "无预约记录或已经到期，请重新预约",
	CreditRecordInformationNoExist: "信用记录信息不存在",
	AccountOrPasswordIsError:       "账号或密码错误",
}

func (c ResCode) Msg() string {
	msg, ok := codeMsgMap[c]
	if !ok {
		return codeMsgMap[CodeServerBusy]
	}
	return msg
}
